package Context;

import java.io.File;
import java.util.Properties;

/**
 * @category Context module
 * @author Sean Lionheart
 * @version 1.0.0.0
 * The context holder which does the initialization work 
 * and provide the context instance. 
 */
public class ContextHolder {
	
	private static Context context;				//The instance of context
	private static XmlParser xmlParser;			//The instance of XmlParser
	
	/**
	 * Get the context instance.
	 * @return Context instance.
	 */
	public static Context getContext() {
		return context;
	}
	/**
	 * Trigger the parser to load the properties.
	 */
	private static void loadProperties() {
		Properties properties = xmlParser.parseProperties();
		context.setProperites(properties);
	}
	/**
	 * Initial the parser and context
	 * After that, the parser will load properties into the context.
	 */
	static {
		xmlParser = new XmlParser(new File(Constant.CONFIGFILENAME));
		context = new Context();
		loadProperties();
	}
}
